/**
 * 
 */
package matrices.centro;

import java.util.ArrayList;

import problema.Utilidades;

import Jama.Matrix;

/**
 * @author usuario_local
 *
 */
public class Clase 
{
	
	

	

	private ArrayList<Matrix> vectores;
	private Matrix centro;

	public Clase(ArrayList<Matrix> vectores, Matrix centro) {
		super();
		this.vectores = vectores;
		this.centro = centro;
	}

	public Clase()
	{
		super();
		this.vectores = new ArrayList<Matrix>();
	}
	/**
	 * 
	 */

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((vectores == null) ? 0 : vectores.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		final Clase other = (Clase) obj;
		if (vectores == null) {
			if (other.vectores != null)
				return false;
		} else if (!vectores.equals(other.vectores))
			return false;
		return true;
	}

	
	

	
	public Matrix getCentro()
	{
		return this.centro;
	}
	
	public ArrayList<Matrix> getElements()
	{
		return vectores;
	}
	
	public void setCentro(Matrix m)
	{
		this.centro = Matrix.constructWithCopy(m.getArray());
	}
	
	public void CreateCentro(Matrix m)
	{
		this.centro = Matrix.constructWithCopy(m.getArray());
		this.vectores.add(m);
	}
	
	public void addElement(Matrix m)
	{
		this.vectores.add(m);
	}
	
	public void deleteElement(Matrix m)
	{
		this.vectores.remove(m);
	}
	
	public void deleteAllElemetns()
	{
		this.vectores = new ArrayList<Matrix>();
	}
	
	@Override
	public String toString() {
		String s = "";
		
		s += Utilidades.matrixToString(this.centro)+"\n";
		s += "Elementos:  \n";
		for(int i = 0; i< this.vectores.size(); i++)
			s += Utilidades.matrixToString(this.vectores.get(i))+"\n";
		
		return s;
	}



}
